#!/usr/bin/env python3



# # 成绩查询
# score = int(input('输入成绩：'))
#
# if score <= 100 and score >= 0:
#     if score >= 90:
#         print("A")
#     elif score >=80:
#         print('B')
#     elif score >= 70:
#         print('B-')
#     elif score >= 60:
#         print('C')
#     elif score < 60:
#         print('D')
# else:
#     print('成绩无效')
#



猜年龄 for循环 优化一
old_boy = 56

count = 0

for i in range(10):
    if count == 3:
        _info = input("您尝试的次数太多是否继续，如果是请输入y")
        if _info == "y":
        pass

    guess_num = int(input("输入年龄："))

    if old_boy == guess_num:
        print('猜对了')
        break
    elif old_boy > guess_num:
        print('猜小了')
    elif old_boy < guess_num:
        print('猜大了')


# 循环跳出
for i in range(10):
    if i == 5:
        for j in range(10):
            if j == 6:
                break
            print(j)
        continue

    print("loop",i)






# 三元运算
a = 4
b = 2

c = a+b if a > b else a-b
print(c)


# ### 增加列表
# names = ['a','b','c','d']
# print(names)
#
# ### 扩展列表
# print(names.extend([1,2,3,4]))
# print(names)
#
# ### 删除列表
# print(names.pop())
# print(names.pop(2))
# print(names)
#
# ### 列表嵌套
# names1 = [['zhangsan',22]['nianling',33]]


### 商品购物车

# shop_info = [['a','100'],['f','500'],['e','1000'],['g','5000']]
#
# for i in enumerate(shop_info):
#     print(i)

# shop_id = input("请输入需要购买的商品id：")
#
# if shop_id == shop_info():
#     print(shop_info[1])




# # 字符串
# name = "My name is fanhongtao"
#
# print(name.capitalize())
# print(name.casefold())
# print(name.)


### 字典

names = {
    "stu101":{"name":"zhangsan","age":"22","hobbie":"girl"},
    "stu102":{"name":"lisi","age":"23","hobbie":"girl"},
    "stu103":{"name":"wangwu","age":"33","hobbie":"girl"},
    "stu104":{"name":"zhaoliu","age":"44","hobbie":"girl"},
}

### 查询

print(names["stu101"]["name"])
print(names["stu102"])
print(names.get("stu105","查无次数"))


### 添加

names["stu105"] = {"name":"user5","age":"43","hobbie":"girl"}
print(names)


### 更新

names["stu101"]["name"] = "fht"
print(names)

### 删除

print(names.pop("stu105"))
print(names)
del names["stu104"]
print(names)


### 复制

names_copy = names.copy()

print(names_copy)










